Listing 13 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 13\13.1601 - No Title.py
# Description: No Title
##############################################################################

def save(self, filename):
    with open(filename, "w") as file:
        data = []
        for site in self.sites.values():
            data.append({"id": site.id, "url": site.url, "notes": site.notes,
                          "date": site.date, "category": site.category})
        json.dump(data, file, indent=2, sort_keys=True)
Click here to download the file